package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysMenu;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysMenuService;
import com.ruoyi.framework.web.base.BaseController;

/**
 * 首页 业务处理
 * 
 * @author ruoyi
 */
@Controller
public class SysIndexController extends BaseController
{
    @Autowired
    private ISysMenuService menuService;

    // 系统首页
    @GetMapping("/index")
    public String index(ModelMap mmap)
    {
    	 String ecrlogin = ecrlogin();
    	 if (StringUtils.isNotEmpty(ecrlogin)) {
    		 return ecrlogin;
		}
    	
        // 取身份信息
        SysUser user = getSysUser();
        // 根据用户id取出菜单
        List<SysMenu> menus = menuService.selectMenusByUser(user);
        mmap.put("menus", menus);
        mmap.put("user", user);
        mmap.put("copyrightYear", Global.getCopyrightYear());
        return "index";
    }

    // main页面
    @GetMapping("/system/main")
    public String main(ModelMap mmap)
    {
        mmap.put("version", Global.getVersion());
        String loginName = getLoginName();
        if (loginName.contains("admin")) {
        	mmap.put("main_title", "尊敬的超级管理员");
		}else if (loginName.contains("caiwu")) {
        	mmap.put("main_title", "尊敬的财务管理员");
		} else if (loginName.contains("kefu")) {
			mmap.put("main_title", "尊敬的客服管理员");
		}else if (loginName.length()>8) {
        	mmap.put("main_title", "尊敬的高级顾问");
		}else {
			mmap.put("main_title", "尊敬的代理商");
		}
        
        return "main";
    }
   
}
